package factory;

/**
 * @Author Zhouchb
 * @Create 2021-12-2021/12/24 :19:33
 * @Description
 */
interface Car{
    void run();
}
class Xiaomi implements Car{

    @Override
    public void run() {
        System.out.println("我是小米汽车");
    }
}
class HuaWei implements Car{

    @Override
    public void run() {
        System.out.println("我是华为汽车");
    }
}
interface CarFactory{
    Car creatCar();
}
class XiaomiFactory implements CarFactory{
    @Override
    public Car creatCar() {
        return new Xiaomi();
    }
}
class HuaWeiFactory implements CarFactory{

    @Override
    public Car creatCar() {
        return new HuaWei();
    }
}
public class FactoryTest {
    public static void main(String[] args) {
        Car xiaomi = new XiaomiFactory().creatCar();
        Car huawei = new HuaWeiFactory().creatCar();
        xiaomi.run();
        huawei.run();
    }
}
